﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using PracticeChart.Popups;
using PracticeChart.DataTypes;

namespace PracticeChart
{
    public partial class Main : Form
    {
        // attributes
        private List<PatientData> patients;
        public int NumberOfPatients { get { return patients.Count; } }
        public Main()
        {
            InitializeComponent();
            patients = new List<PatientData>();
        }

        private void editTimesButton_Click(object sender, EventArgs e)
        {
            // save dates
            string[] dates = { 
                onsetLabel.Text.Split(' ')[0],
                dispatchedLabel.Text.Split(' ')[0],
                enrouteLabel.Text.Split(' ')[0],
                onsceneLabel.Text.Split(' ')[0],
                atpatientLabel.Text.Split(' ')[0],
                deprefLabel.Text.Split(' ')[0],
                arcrecLabel.Text.Split(' ')[0],
                xfercareLabel.Text.Split(' ')[0],
                availableLabel.Text.Split(' ')[0]
                             };
            // save times
            string[] times = {
                onsetLabel.Text.Split(' ')[1],
                dispatchedLabel.Text.Split(' ')[1],
                enrouteLabel.Text.Split(' ')[1],
                onsceneLabel.Text.Split(' ')[1],
                atpatientLabel.Text.Split(' ')[1],
                deprefLabel.Text.Split(' ')[1],
                arcrecLabel.Text.Split(' ')[1],
                xfercareLabel.Text.Split(' ')[1],
                availableLabel.Text.Split(' ')[1]
                             };



            Times runTimes = new Times(dates,times, this);
            runTimes.Show();
            runTimes.Activate();
        }

        private void addPatientButton_Click(object sender, EventArgs e)
        {
            Patient p = new Patient(this);
            p.Activate();
            p.Show();
        }

        internal void AddPatient(PatientData pt)
        {
            if (pt == null)
            {
                patientsLabel.Text = "1) No Patient Selected";
            }
            else
            {
                patients.Add(pt);
                string endl = "\r\n";
                StringBuilder ptText = new StringBuilder();
                for (int i = 0; i < patients.Count; i++)
                {
                    ptText.Append(i + 1);
                    ptText.Append(") ");
                    ptText.Append(pt.First);
                    ptText.Append(" ");
                    ptText.Append(pt.Last);
                    ptText.Append(endl);
                }
                patientsLabel.Text = ptText.ToString();

            }
        }
    }
}
